package cvsexercise8;

/* Create the Rectangle class declaration according to the UML
 * by creating a subclass of the Shape class from Exercise 12
 * include (private) instance variables to store the length and width (double)
 * include a constructor that calls the superclass constructor 
 * include a getter method to return the length (double) - getLength()
 * include a getter method to return the width (double) - getWidth()
 * include an overridden getArea() method to return the area of the rectangle (width x length)
 * include an overridden toString() method to output the type of subclass (i.e. "subclass of super.toString()")
 */
public class Rectangle extends Shape {

	/* private instance variables */
	private double length;
	private double width;
	
	/* constructor (takes a string and two double parameters) */
	public Rectangle(String colour, double length, double width) {
		
		/* call the superclass constructor, passing the string as an argument */
		super(colour);
		
		/* set the classes private instance variables */
		this.length = length;
		this.width = width;
	}
	
	/* getter method to return the length (as a double) */
	public double getLength() {
		return length;
	}
	
	/* getter method to return the width (as a double) */
	public double getWidth() {
		return width;
	}
	
	/* override the getArea() method to return the area of the rectangle (double) */
	@Override
	public double getArea() {
		return (length * width);
	}
	
	/* override the toString() method to write out the type of superclass */
	@Override 
	public String toString() {
		return ("Rectangle is a subclass of " + super.toString());
	}
}
